﻿using ET.DBCommon.Model;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ET.DBCommon.DAL
{
    public class VoiceLibraryLogDAL
    {
        public static bool InsertVoiceLibraryLogDAL(VoiceLibraryLogModel voicelibraryLog)
        {
            string sql = @"INSERT INTO `voicelibrarylog`
                            (`UserID`,
                            `ExamResultsID`,
                            `OperTime`,
                            `VirtualTime`,
                            `DevType`,
                            `DevTypeName`,
                            `TalkContent`,
                            `ReplyContent`,
                            `AudioFile`,
                            `CommandStep`,
                            `Parameter`)
                            VALUES
                            (@UserID,
                            @ExamResultsID,
                            now(6),
                            @VirtualTime,
                            @DevType,
                            @DevTypeName,
                            @TalkContent,
                            @ReplyContent,
                            @AudioFile,
                            @CommandStep,
                            @Parameter)";
            MySqlParameter[] parms = {
                new MySqlParameter("@UserID", voicelibraryLog.UserID ),
                new MySqlParameter("@ExamResultsID", voicelibraryLog.ExamResultsID),
                new MySqlParameter("@VirtualTime", voicelibraryLog.VirtualTime),

                new MySqlParameter("@DevType", voicelibraryLog.DevType),
                new MySqlParameter("@DevTypeName", string.IsNullOrWhiteSpace(voicelibraryLog.DevTypeName)?"":voicelibraryLog.DevTypeName),
                new MySqlParameter("@TalkContent", string.IsNullOrWhiteSpace(voicelibraryLog.TalkContent)?"":voicelibraryLog.TalkContent),
                new MySqlParameter("@ReplyContent", string.IsNullOrWhiteSpace(voicelibraryLog.ReplyContent)?"":voicelibraryLog.ReplyContent),
                new MySqlParameter("@AudioFile", voicelibraryLog.AudioFile),
                new MySqlParameter("@CommandStep", string.IsNullOrWhiteSpace(voicelibraryLog.CommandStep)?"":voicelibraryLog.CommandStep),
                new MySqlParameter("@Parameter", string.IsNullOrWhiteSpace(voicelibraryLog.Parameter)?"":voicelibraryLog.Parameter),
            };
            return DbHelperLog.ExecuteNonQuery(sql, parms) > 0;
        }
    }
}
